<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of description
 *
 * @author Chris Sim
 */
 $description = array();
 foreach($models as $model) {
     foreach($model->description() as $m) {
        $description[$model->ref_no][] = $m;  
     }
 }

?>
<?php foreach($description as $ref=>$descs): ?>
<fieldset class="ui-widget">
    <legend class="ui-widget-header ui-corner-all"><?php echo $ref ?></legend>
    <table class="ui-widget-content" style="width:100%;">
    <tr>
        <th class="ui-widget-header"><?php echo CHtml::encode($descs[0]->getAttributeLabel('do_details_id')) ?></th>
        <th class="ui-widget-header"><?php echo CHtml::encode($descs[0]->getAttributeLabel('marking')) ?></th>
        <th class="ui-widget-header"><?php echo CHtml::encode($descs[0]->getAttributeLabel('item')) ?></th>
        <th class="ui-widget-header"><?php echo CHtml::encode($descs[0]->getAttributeLabel('qty')) ?></th>
    </tr>
    <?php foreach($descs as $i=>$model):  ?>
    <tr>
        <td><?php echo CHtml::encode($model->do_details_id); ?></td>
        <td><?php echo CHtml::encode($model->marking); ?></td>
        <td><?php echo CHtml::encode($model->item); ?></td>
        <td><?php echo CHtml::encode($model->qty); ?><?php echo CHtml::encode($model->qty_type); ?></td>
    </tr>
    <?php endforeach; ?>
</table>
</fieldset>
<?php endforeach; ?>
